package com.dreem.principle.inversion.improve;

/**
 * @program: DesignParrtern
 * @description:
 * @author: Peng
 * @create: 2021-01-16  09:57
 **/
public class DependencyInversionUP01 {
    public static void main(String[] args){
        ITV tv = new ITV() {
            @Override
            public void play() {
                System.out.println("CCTV14正在播放！");
            }
        };
        new OpenAndClose().open(tv);
    }
}

// 通过接口实现依赖
// 方式1
interface IOpenAndClose{
    public void open(ITV tv);// 抽象方法，接收窗口
}

interface ITV{ // ITV接口
    public void play();
}

// 实现接口
class OpenAndClose implements IOpenAndClose {

    @Override
    public void open(ITV tv) {
        tv.play();
    }
}
